import { defineStore } from "pinia";

export const useTabStore = defineStore("tabStore", {
  state: () => ({
    tabList: [
      {
        name: "1",
        label: "主界面",
        closable: false,
        paneName: "1",
      },
    ],
    activeTabName: '1',
  }),
  persist: true, // 启用持久化
  getters: {
    TabsGetter: (state) => {
      return state.tabList;
    },
    activeTabNameGetter: (state) => {
      return state.activeTabName;
    },
  },
  actions: {    
    addTabList(obj: any) {
      this.tabList.push(obj);
    },
    setTabList(list: any) {
      this.tabList.splice(0);
      this.tabList.push(...list);
    },
    setActiveTabName(val: any) {
      this.activeTabName = val;
    },
    clearAllTabs(){
      this.tabList.splice(1,this.tabList.length);
      
    }
  },
});
